<?php
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Machine;
use Dingo\Api\Http\Request;
use Illuminate\Support\Facades\DB;

class ShopController extends Controller
{
    protected $model;

    public function __construct(Machine $machine )
    {
        $this->model = $machine;
    }

    public function shopInfo(Request $request){
        $machineId = $request->machineId;
        $result = DB::table('machines')
            ->select('admin_users.phone as telphone','machines.name as machinesname','machines.imei as machimei','machines.is_cart as iscart')
            ->leftJoin('machine_managers','machine_managers.machine_id','=','machines.id')
            ->leftJoin('admin_users','admin_users.id','=','machine_managers.manager_id')
            ->where('machines.id',$machineId)
            ->first();
        return $this->success($result);
    }
}
